package com.googlecode.wicketcharts.highcharts.gson;

import java.awt.Color;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.googlecode.wicketcharts.highcharts.options.AxisType;
import com.googlecode.wicketcharts.highcharts.options.HorizontalAlignment;
import com.googlecode.wicketcharts.highcharts.options.SeriesType;
import com.googlecode.wicketcharts.highcharts.options.VerticalAlignment;

/**
 * Factory for {@link Gson} objects to be used by the Highcharts abstraction for
 * translation into JSON.
 * 
 * @author Tom
 * 
 */
public class GsonFactory {

	public static Gson createGson() {
		GsonBuilder builder = new GsonBuilder();
		builder.registerTypeAdapter(AxisType.class, new GsonLowercaseEnumSerializer());
		builder.registerTypeAdapter(SeriesType.class, new GsonLowercaseEnumSerializer());
		builder.registerTypeAdapter(HorizontalAlignment.class, new GsonLowercaseEnumSerializer());
		builder.registerTypeAdapter(VerticalAlignment.class, new GsonLowercaseEnumSerializer());
		builder.registerTypeAdapter(Color.class, new GsonColorSerializer());
		builder.setPrettyPrinting();
		return builder.create();
	}

}
